﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;

using H2.NET.Business;

namespace H2.NET.Web.Pages
{
    public partial class Finance : TaskControl
    {
        #region 属性 Public
        public string FORM
        {
            get
            {
                return (Parent as TabMaterial).Status.FORM;
            }
        }

        public string Category
        {
            get
            {
                return (Parent as TabMaterial).Status.Category;
            }
        }

        public string Action
        {
            get
            {
                return (Parent as TabMaterial).Status.Finance;
            }
        }

        private bool IsLoaded
        {
            get
            {
                return ViewState["IsLoaded"] == null ? false : (bool)ViewState["IsLoaded"];
            }
            set { ViewState["IsLoaded"] = value; }
        }

        private bool IsUsed
        {
            get
            {
                //return !(string.IsNullOrEmpty(FORM) || string.IsNullOrEmpty(Action)
                //    || (FORM != "FORM-001" && FORM != "FORM-002" && FORM != "FORM-005" && FORM != "FORM-009" && FORM != "FORM-012" && FORM != "FORM-035" && FORM != "FORM-064" && FORM != "FORM-036" && FORM != "FORM-043"));
                return !string.IsNullOrEmpty(Action);
            }
        }
        #endregion

        #region 事件 页面加载
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Visible = IsUsed;
        }
        #endregion

        #region 方法 InitControls(初始化)
        public void InitControls(mdc_Material mt)
        {
            //如果当前 Tabs 是隐藏的情况，退出
            Visible = IsUsed;
            if (!IsUsed)
            {
                return;
            }

            InitShowHide();

           // if (!IsLoaded)
           // {
                InitDropDownList();
            //}

            Distribute(mt);

            SetForeColor(Color.Black, FIN_With_Qty_Structure_L, FIN_Do_Not_Cost_L, FIN_Moving_Price_L, FIN_Valuation_Class_L, FIN_Material_Origin_L, FIN_Costing_Lot_Size_L, FIN_Price_Control_L, FIN_Price_Unit_L, FIN_Origin_Group_L, FIN_Profit_Center_L, FIN_Currency_L, FIN_Variance_Key_L);

            if (TaskAPI.IsAllowSubmit)
            {
                switch (Action)
                {
                    case "C":
                        SetEnable(true, FIN_Moving_Price,FIN_Valuation_Class, FIN_Material_Origin, FIN_Costing_Lot_Size, FIN_Price_Control, FIN_Price_Unit, FIN_Origin_Group, FIN_Profit_Center, FIN_Currency, FIN_Variance_Key);
                        SetForeColor(Color.Blue, FIN_Moving_Price_L);
                        SetEnable(true, FIN_With_Qty_Structure, FIN_Do_Not_Cost);
                        SetDefaultValue();
                        break;
                    case "S":
                        SetEnable(false, FIN_With_Qty_Structure, FIN_Do_Not_Cost);
                        SetEnable(false,FIN_Moving_Price, FIN_Valuation_Class, FIN_Material_Origin, FIN_Costing_Lot_Size, FIN_Price_Control, FIN_Price_Unit, FIN_Origin_Group, FIN_Profit_Center, FIN_Currency, FIN_Variance_Key);
                        if (FORM == "FORM-015" && TaskAPI.IsBeginStep)
                        {
                            SetEnable(true, FIN_Moving_Price);
                        }
                        SetDefaultValue();
                        SetForeColor(Color.Black,FIN_With_Qty_Structure_L, FIN_Do_Not_Cost_L,FIN_Moving_Price_L, FIN_Valuation_Class_L, FIN_Material_Origin_L, FIN_Costing_Lot_Size_L, FIN_Price_Control_L, FIN_Price_Unit_L, FIN_Origin_Group_L, FIN_Profit_Center_L, FIN_Currency_L, FIN_Variance_Key_L);

                        break;
                    case "E":
                        SetEnable(true, FIN_With_Qty_Structure, FIN_Do_Not_Cost);
                        SetEnable(true,FIN_With_Qty_Structure_L, FIN_Do_Not_Cost_L,FIN_Moving_Price, FIN_Valuation_Class, FIN_Material_Origin, FIN_Costing_Lot_Size, FIN_Price_Control, FIN_Price_Unit, FIN_Origin_Group, FIN_Profit_Center, FIN_Currency, FIN_Variance_Key);
                        SetForeColor(Color.Black,FIN_Moving_Price_L, FIN_Valuation_Class_L, FIN_Material_Origin_L, FIN_Costing_Lot_Size_L, FIN_Price_Control_L, FIN_Price_Unit_L, FIN_Origin_Group_L, FIN_Profit_Center_L, FIN_Currency_L, FIN_Variance_Key_L);
                        SetForeColor(Color.Blue, FIN_Moving_Price_L);
                        SetDefaultValue();
                        break;
                }
            }
            else
            {
                SetEnable(false,FIN_Moving_Price, FIN_Valuation_Class, FIN_Material_Origin, FIN_Costing_Lot_Size, FIN_Price_Control, FIN_Price_Unit, FIN_Origin_Group, FIN_Profit_Center, FIN_Currency, FIN_Variance_Key,FIN_Do_Not_Cost,FIN_With_Qty_Structure);
            }
            //魏军添加 控制dropdownlist的enable属性
            string item = "";
            string value = "";
            bool flag_2 = false;
            foreach (Control cr in this.Controls)
            {
                if (cr is DropDownList)
                {
                    DropDownList tb = (DropDownList)cr;
                    if (!tb.Enabled)
                    {

                        try
                        {
                            item = tb.SelectedItem.Text;
                            value = tb.SelectedValue.ToString();
                        }
                        catch (Exception)
                        {
                            flag_2 = true;

                        }
                        if (!flag_2)
                        {
                            tb.Enabled = true;
                            tb.Items.Clear();
                            tb.Items.Add(new ListItem(item, value));
                            tb.SelectedIndex = 0;
                            tb.ForeColor = System.Drawing.Color.DimGray;
                        }
                    }

                }
            }
        }
        #endregion

        #region 方法 InitDropdownList(初始化下拉框数据源)
        private void InitDropDownList()
        {

            FIN_Valuation_Class.Items.Add(new ListItem("", ""));
            FIN_Valuation_Class.Items.Add(new ListItem("3000", "3000"));
            FIN_Valuation_Class.Items.Add(new ListItem("3050", "3050"));
            FIN_Valuation_Class.Items.Add(new ListItem("7900", "7900"));
            FIN_Valuation_Class.Items.Add(new ListItem("7920", "7920"));
            FIN_Valuation_Class.Items.Add(new ListItem("Z001", "Z001"));
            FIN_Valuation_Class.Items.Add(new ListItem("Z005", "Z005"));
            FIN_Valuation_Class.SelectedIndex = 0;
            FIN_Profit_Center.Items.Clear();
            FIN_Profit_Center.Items.Add(new ListItem("", ""));
            IList<m_ProfitCenter> pcs = null;
            if (TaskAPI.Process == "TW New Raw Material Creation" || TaskAPI.Process == "TW Pack Material Maintenance" || TaskAPI.Process == "TW Raw Code Application")
            {
                pcs = (m_ProfitCenter.status == 1 & m_ProfitCenter.company=="TW").List<m_ProfitCenter>();
            }
            else
            {
                pcs = (m_ProfitCenter.status == 1).List<m_ProfitCenter>();
            }
            foreach (m_ProfitCenter pc in pcs)
            {
                bool Flg = true;
                foreach (ListItem li in FIN_Profit_Center.Items)
                {
                    if (pc.Profit_Center == li.Value)
                    {
                        Flg = false;
                        break;
                    }
                }

                if (Flg)
                {
                    FIN_Profit_Center.Items.Add(new ListItem(pc.Profit_Center + ", " + pc.Channel, pc.Profit_Center));
                }
            }
        }
        #endregion

        #region 方法 InitShowHide(初始化控件显示)
        private void InitShowHide()
        {
            #region 设置禁启用
            SetVisible(false, FIN_Moving_Price, FIN_Moving_Price_L,FIN_Valuation_Class, FIN_Material_Origin, FIN_Costing_Lot_Size, FIN_Price_Control, FIN_Price_Unit, FIN_Origin_Group, FIN_Profit_Center, FIN_Currency, FIN_Variance_Key
                            ,FIN_With_Qty_Structure_L,FIN_With_Qty_Structure,FIN_Do_Not_Cost_L,FIN_Do_Not_Cost, FIN_Valuation_Class_L, FIN_Material_Origin_L, FIN_Costing_Lot_Size_L, FIN_Price_Control_L, FIN_Price_Unit_L, FIN_Origin_Group_L, FIN_Profit_Center_L, FIN_Currency_L, FIN_Variance_Key_L);

            switch (FORM)
            {
                case "FORM-001":
                    SetVisible(true, FIN_Valuation_Class, FIN_Material_Origin, FIN_Costing_Lot_Size, FIN_Price_Control, FIN_Price_Unit, FIN_Variance_Key
                           , FIN_Valuation_Class_L, FIN_Material_Origin_L, FIN_Costing_Lot_Size_L, FIN_Price_Control_L, FIN_Price_Unit_L, FIN_Variance_Key_L);
                    break;
                case "FORM-002":
                case "FORM-005":
                case "FORM-009":
                case "FORM-012":
                case "FORM-077":
                //case "FORM-062":
                case "FORM-064":
                case "FORM-074":
                    if (FORM == "FORM-064" || FORM == "FORM-074")     //Form-062 HK Fini code  NPL V2.0 100925  && Form-064 HK Trade Code V2.0 100925.xls
                    {
                        FIN_Title.Text = "&nbsp;";
                    }

                    SetVisible(true, FIN_Valuation_Class, FIN_Material_Origin, FIN_Costing_Lot_Size, FIN_Price_Control, FIN_Price_Unit, FIN_Origin_Group, FIN_Profit_Center, FIN_Currency, FIN_Variance_Key
                           , FIN_Valuation_Class_L, FIN_Material_Origin_L, FIN_Costing_Lot_Size_L, FIN_Price_Control_L, FIN_Price_Unit_L, FIN_Origin_Group_L, FIN_Profit_Center_L, FIN_Currency_L, FIN_Variance_Key_L);
                    
                    if (FORM == "FORM-064")
                    {
                        SetVisible(false, FIN_Currency, FIN_Currency_L, FIN_Profit_Center, FIN_Profit_Center_L, FIN_Origin_Group, FIN_Origin_Group_L,
                                          FIN_Costing_Lot_Size, FIN_Costing_Lot_Size_L);
                    }

                    if (FORM == "FORM-074")
                    {
                        SetVisible(false, FIN_Profit_Center, FIN_Profit_Center_L, FIN_Origin_Group, FIN_Origin_Group_L, FIN_Currency, FIN_Currency_L);
                    }

                    break;
                case "FORM-062-1":
                    SetVisible(true, FIN_Valuation_Class, FIN_Material_Origin, FIN_Costing_Lot_Size, FIN_Price_Control, FIN_Price_Unit, FIN_Origin_Group, FIN_Profit_Center, FIN_Currency, FIN_Variance_Key
                           , FIN_Valuation_Class_L, FIN_Material_Origin_L, FIN_Costing_Lot_Size_L, FIN_Price_Control_L, FIN_Price_Unit_L, FIN_Origin_Group_L, FIN_Profit_Center_L, FIN_Currency_L, FIN_Variance_Key_L);
                    break;
                case "FORM-035":
                    FIN_Title.Text = "&nbsp;";
                    SetVisible(true, FIN_Valuation_Class, FIN_Material_Origin, FIN_Costing_Lot_Size, FIN_Price_Control, FIN_Price_Unit, FIN_Currency, FIN_Variance_Key
                           , FIN_Valuation_Class_L, FIN_Material_Origin_L, FIN_Costing_Lot_Size_L, FIN_Price_Control_L, FIN_Price_Unit_L, FIN_Currency_L, FIN_Variance_Key_L);
                    break;
                case "FORM-036":
                    FIN_Title.Text = "&nbsp;";
                    SetVisible(true, FIN_Valuation_Class, FIN_Material_Origin, FIN_Costing_Lot_Size, FIN_Price_Control, FIN_Price_Unit, FIN_Currency, FIN_Origin_Group, FIN_Profit_Center
                           , FIN_Valuation_Class_L, FIN_Material_Origin_L, FIN_Costing_Lot_Size_L, FIN_Price_Control_L, FIN_Price_Unit_L, FIN_Currency_L, FIN_Origin_Group_L, FIN_Profit_Center_L);
                    break;
                case "FORM-043":
                    FIN_Title.Text = "&nbsp;";
                    SetVisible(true, FIN_Valuation_Class, FIN_Material_Origin, FIN_Costing_Lot_Size, FIN_Price_Control, FIN_Price_Unit, FIN_Currency, FIN_Variance_Key, FIN_Origin_Group
                                   , FIN_Valuation_Class_L, FIN_Material_Origin_L, FIN_Costing_Lot_Size_L, FIN_Price_Control_L, FIN_Price_Unit_L, FIN_Currency_L, FIN_Variance_Key_L, FIN_Origin_Group_L);
                    break;
                case "FORM-031-1":
                    FIN_Title.Text = "&nbsp;";
                    SetVisible(true, FIN_Valuation_Class, FIN_Material_Origin, FIN_Costing_Lot_Size, FIN_Price_Control, FIN_Price_Unit, FIN_Variance_Key
                                   , FIN_Valuation_Class_L, FIN_Material_Origin_L, FIN_Costing_Lot_Size_L, FIN_Price_Control_L, FIN_Price_Unit_L, FIN_Variance_Key_L);
                    break;
                case "FORM-031-2":
                    FIN_Title.Text = "&nbsp;";
                    SetVisible(true, FIN_Valuation_Class, FIN_Material_Origin, FIN_Costing_Lot_Size, FIN_Price_Control, FIN_Price_Unit, FIN_Variance_Key
                                   , FIN_Valuation_Class_L, FIN_Material_Origin_L, FIN_Costing_Lot_Size_L, FIN_Price_Control_L, FIN_Price_Unit_L, FIN_Variance_Key_L);
                    break;
                case "FORM-067":
                    FIN_Title.Text = "&nbsp;";
                    SetVisible(true, FIN_Valuation_Class, FIN_Material_Origin, FIN_Costing_Lot_Size, FIN_Price_Control, FIN_Price_Unit, FIN_Variance_Key
                                   , FIN_Valuation_Class_L, FIN_Material_Origin_L, FIN_Costing_Lot_Size_L, FIN_Price_Control_L, FIN_Price_Unit_L, FIN_Variance_Key_L);
                    break;
                case "FORM-015":
                    FIN_Title.Text = "&nbsp;";
                    SetVisible(true,FIN_Moving_Price,FIN_Moving_Price_L, FIN_Valuation_Class, FIN_Price_Control, FIN_Price_Unit
                                   , FIN_Valuation_Class_L, FIN_Price_Control_L, FIN_Price_Unit_L);
                    break;
                case "FORM-010":
                    SetVisible(true, FIN_Material_Origin, FIN_Material_Origin_L, FIN_Valuation_Class, FIN_Valuation_Class_L, FIN_Variance_Key, FIN_Variance_Key_L
                                   , FIN_Price_Control, FIN_Price_Control_L, FIN_Price_Unit, FIN_Price_Unit_L, FIN_Costing_Lot_Size, FIN_Costing_Lot_Size_L);
                    break;
                case "FORM-062":
                    SetVisible(true, FIN_Costing_Lot_Size, FIN_Costing_Lot_Size_L, FIN_Material_Origin, FIN_Material_Origin_L, FIN_Price_Unit, FIN_Price_Unit_L
                                   , FIN_Price_Control, FIN_Price_Control_L, FIN_Variance_Key, FIN_Variance_Key_L, FIN_Valuation_Class, FIN_Valuation_Class_L);
                    break;
                case "FORM-T012":
                case "FORM-T009":
                    SetVisible(true, FIN_Valuation_Class, FIN_Valuation_Class_L, FIN_Price_Control, FIN_Price_Control_L, FIN_Price_Unit, FIN_Price_Unit_L, FIN_Profit_Center, FIN_Profit_Center_L);
                    break;
                case "FORM-T006":
                    SetVisible(true, FIN_Valuation_Class, FIN_Valuation_Class_L, FIN_Price_Control, FIN_Price_Control_L, FIN_Price_Unit, FIN_Price_Unit_L, FIN_Do_Not_Cost,FIN_Do_Not_Cost_L
                                   , FIN_With_Qty_Structure, FIN_With_Qty_Structure_L, FIN_Material_Origin, FIN_Material_Origin_L, FIN_Variance_Key, FIN_Variance_Key_L
                                   , FIN_Costing_Lot_Size, FIN_Costing_Lot_Size_L);
                    break;
                case "FORM-TW-003":
                    SetVisible(true, FIN_Valuation_Class, FIN_Valuation_Class_L, FIN_Price_Control, FIN_Price_Control_L, FIN_Price_Unit, FIN_Price_Unit_L, FIN_Material_Origin_L, FIN_Material_Origin
                                    , FIN_Origin_Group_L, FIN_Origin_Group, FIN_Profit_Center_L, FIN_Profit_Center, FIN_Variance_Key_L, FIN_Variance_Key,
                                    FIN_Profit_Center,FIN_Profit_Center_L,FIN_Costing_Lot_Size, FIN_Costing_Lot_Size_L,FIN_Do_Not_Cost,FIN_Do_Not_Cost_L,FIN_With_Qty_Structure,FIN_With_Qty_Structure_L);
                    break;
                case "FORM-TW-010":
                    SetVisible(true, FIN_Valuation_Class, FIN_Valuation_Class_L, FIN_Price_Control, FIN_Price_Control_L, FIN_Price_Unit, FIN_Price_Unit_L, FIN_Material_Origin_L, FIN_Material_Origin
                                    ,  FIN_Variance_Key_L, FIN_Variance_Key, FIN_Costing_Lot_Size, FIN_Costing_Lot_Size_L, FIN_Do_Not_Cost, FIN_Do_Not_Cost_L, FIN_With_Qty_Structure, FIN_With_Qty_Structure_L);
                    break;
                case "FORM-TW-004":
                    SetVisible(true,FIN_Origin_Group,FIN_Origin_Group_L, FIN_Valuation_Class, FIN_Valuation_Class_L, FIN_Price_Control, FIN_Price_Control_L, FIN_Price_Unit, FIN_Price_Unit_L, FIN_Material_Origin_L, FIN_Material_Origin
                                    , FIN_Profit_Center_L, FIN_Profit_Center, FIN_Variance_Key_L, FIN_Variance_Key, FIN_Costing_Lot_Size, FIN_Costing_Lot_Size_L, FIN_Do_Not_Cost, FIN_Do_Not_Cost_L, FIN_With_Qty_Structure, FIN_With_Qty_Structure_L);
                    break;
                case "FORM-TW-011":
                    SetVisible(true, FIN_Valuation_Class, FIN_Valuation_Class_L, FIN_Price_Control, FIN_Price_Control_L, FIN_Price_Unit, FIN_Price_Unit_L, FIN_Material_Origin_L, FIN_Material_Origin
                                    , FIN_Profit_Center_L,FIN_Profit_Center,FIN_Variance_Key_L, FIN_Variance_Key, FIN_Costing_Lot_Size, FIN_Costing_Lot_Size_L, FIN_Do_Not_Cost, FIN_Do_Not_Cost_L, FIN_With_Qty_Structure, FIN_With_Qty_Structure_L);
                    break;
                case "FORM-TW-007":
                    SetVisible(true, FIN_Valuation_Class, FIN_Valuation_Class_L, FIN_Price_Control, FIN_Price_Control_L, FIN_Price_Unit, FIN_Price_Unit_L, FIN_Material_Origin_L, FIN_Material_Origin
                                    , FIN_Variance_Key_L, FIN_Variance_Key, FIN_Costing_Lot_Size, FIN_Costing_Lot_Size_L, FIN_Do_Not_Cost, FIN_Do_Not_Cost_L, FIN_With_Qty_Structure, FIN_With_Qty_Structure_L);
                    break;
                case "FORM-TW-007-1":
                    SetVisible(true, FIN_Valuation_Class, FIN_Valuation_Class_L, FIN_Price_Control, FIN_Price_Control_L, FIN_Price_Unit, FIN_Price_Unit_L, FIN_Material_Origin_L, FIN_Material_Origin, FIN_Profit_Center_L, FIN_Profit_Center
                                    , FIN_Variance_Key_L, FIN_Variance_Key, FIN_Costing_Lot_Size, FIN_Costing_Lot_Size_L, FIN_Do_Not_Cost, FIN_Do_Not_Cost_L, FIN_With_Qty_Structure, FIN_With_Qty_Structure_L);
                    break;
                case "FORM-T008":
                    SetVisible(true, FIN_Valuation_Class, FIN_Valuation_Class_L, FIN_Price_Unit, FIN_Price_Unit_L, FIN_Price_Control, FIN_Price_Control_L, FIN_With_Qty_Structure, FIN_With_Qty_Structure_L
                                   , FIN_Material_Origin, FIN_Material_Origin_L, FIN_Do_Not_Cost, FIN_Do_Not_Cost_L, FIN_Variance_Key, FIN_Variance_Key_L, FIN_Costing_Lot_Size, FIN_Costing_Lot_Size_L
                                   , FIN_Profit_Center, FIN_Profit_Center_L);
                    break;
                case"FORM-T010":
                    SetVisible(true, FIN_Valuation_Class, FIN_Valuation_Class_L, FIN_Price_Control, FIN_Price_Control_L, FIN_Price_Unit, FIN_Price_Unit_L, FIN_Do_Not_Cost, FIN_Do_Not_Cost_L
                                   , FIN_With_Qty_Structure, FIN_With_Qty_Structure_L, FIN_Material_Origin, FIN_Material_Origin_L, FIN_Variance_Key, FIN_Variance_Key_L, FIN_Costing_Lot_Size, FIN_Costing_Lot_Size_L);
                    break;
                case "FORM-T011":
                    SetVisible(true, FIN_Valuation_Class, FIN_Valuation_Class_L, FIN_Price_Unit, FIN_Price_Unit_L, FIN_Price_Control, FIN_Price_Control_L, FIN_With_Qty_Structure, FIN_With_Qty_Structure_L
                                   , FIN_Material_Origin, FIN_Material_Origin_L, FIN_Do_Not_Cost, FIN_Do_Not_Cost_L, FIN_Variance_Key, FIN_Variance_Key_L, FIN_Costing_Lot_Size, FIN_Costing_Lot_Size_L
                                   , FIN_Profit_Center, FIN_Profit_Center_L);
                    break;
                case "FORM-T003":
                    SetVisible(true, FIN_Valuation_Class, FIN_Valuation_Class_L, FIN_Price_Unit, FIN_Price_Unit_L, FIN_Price_Control, FIN_Price_Control_L, FIN_Do_Not_Cost, FIN_Do_Not_Cost_L, FIN_Origin_Group, FIN_Origin_Group_L, FIN_With_Qty_Structure, FIN_With_Qty_Structure_L, FIN_Variance_Key, FIN_Variance_Key_L, FIN_Material_Origin, FIN_Material_Origin_L, FIN_Profit_Center, FIN_Profit_Center_L, FIN_Costing_Lot_Size, FIN_Costing_Lot_Size_L);
                    break;
                case "FORM-T018":
                    SetVisible(true, FIN_Valuation_Class, FIN_Valuation_Class_L, FIN_Price_Unit, FIN_Price_Unit_L, FIN_Price_Control, FIN_Price_Control_L, FIN_Do_Not_Cost, FIN_Do_Not_Cost_L, FIN_Origin_Group, FIN_Origin_Group_L, FIN_With_Qty_Structure, FIN_With_Qty_Structure_L, FIN_Variance_Key, FIN_Variance_Key_L, FIN_Material_Origin, FIN_Material_Origin_L, FIN_Profit_Center, FIN_Profit_Center_L, FIN_Costing_Lot_Size, FIN_Costing_Lot_Size_L);
                    break;
                case "FORM-T007":
                    SetVisible(true, FIN_Valuation_Class, FIN_Valuation_Class_L, FIN_Price_Control, FIN_Price_Control_L, FIN_Price_Unit, FIN_Price_Unit_L, FIN_Material_Origin_L, FIN_Material_Origin, FIN_Profit_Center, FIN_Profit_Center_L
                                    , FIN_Variance_Key_L, FIN_Variance_Key, FIN_Costing_Lot_Size, FIN_Costing_Lot_Size_L, FIN_Do_Not_Cost, FIN_Do_Not_Cost_L, FIN_With_Qty_Structure, FIN_With_Qty_Structure_L);
                    break;
                case "FORM-T011-1":
                    SetVisible(true, FIN_Valuation_Class, FIN_Valuation_Class_L, FIN_Price_Control, FIN_Price_Control_L, FIN_Price_Unit, FIN_Price_Unit_L, FIN_Material_Origin_L, FIN_Material_Origin, FIN_Profit_Center, FIN_Profit_Center_L
                                    , FIN_Variance_Key_L, FIN_Variance_Key, FIN_Costing_Lot_Size, FIN_Costing_Lot_Size_L, FIN_Do_Not_Cost, FIN_Do_Not_Cost_L, FIN_With_Qty_Structure, FIN_With_Qty_Structure_L);
                    break;
            }

            SetToolTip();
            #endregion
        }
        #endregion

        #region 方法 Distribute,Collect(分发, 收集值)
        public void Distribute(mdc_Material mt)
        {
            //如果当前 Tabs 是隐藏的情况，退出
            if (!IsUsed)
            {
                return;
            }
            try
            {
                FIN_Valuation_Class.SelectedValue = mt.FIN_Valuation_Class;
            }
            catch (Exception)
            {
                FIN_Valuation_Class.Items.Clear();
                FIN_Valuation_Class.Items.Add(new ListItem(mt.FIN_Valuation_Class, mt.FIN_Valuation_Class));
                FIN_Valuation_Class.SelectedValue = mt.FIN_Valuation_Class;   
     
            }
          
    
            FIN_Material_Origin.Checked         = mt.FIN_Material_Origin == "1";
            FIN_Do_Not_Cost.Checked             = mt.FIN_Do_Not_Cost == "1";
            FIN_With_Qty_Structure.Checked      = mt.FIN_With_Qty_Structure == "1"; 
            FIN_Costing_Lot_Size.Text           = mt.FIN_Costing_Lot_Size;
            try
            {
                FIN_Price_Control.SelectedValue     = mt.FIN_Price_Control; 
            }
            catch (Exception)
            {
                FIN_Price_Control.Items.Clear();
                FIN_Price_Control.Items.Add(new ListItem(mt.FIN_Price_Control, mt.FIN_Price_Control));
                FIN_Price_Control.SelectedValue = mt.FIN_Price_Control;   
            }
            FIN_Price_Unit.Text                 = mt.FIN_Price_Unit;      
            FIN_Origin_Group.Text               = mt.FIN_Origin_Group;    
            FIN_Profit_Center.SelectedValue     = mt.FIN_Profit_Center;   
            FIN_Currency.Text                   = mt.FIN_Currency;        
            FIN_Variance_Key.Text               = mt.FIN_Variance_Key;
            FIN_Moving_Price.Text               = mt.FIN_Moving_Price;
            FIN_With_Qty_Structure.Checked = mt.FIN_With_Qty_Structure == "1";
            FIN_Do_Not_Cost.Checked = mt.FIN_Do_Not_Cost == "1";
        }

        public void Collect(ref mdc_Material mt)
        {
            //如果当前 Tabs 是隐藏的情况，退出
            if (!IsUsed)
            {
                return;
            }

            mt.FIN_Valuation_Class   = FIN_Valuation_Class.SelectedValue;
            mt.FIN_Material_Origin   = FIN_Material_Origin.Checked ? "1" : "0";
            mt.FIN_Do_Not_Cost       = FIN_Do_Not_Cost.Checked ? "1" : "0";
            mt.FIN_With_Qty_Structure= FIN_With_Qty_Structure.Checked ? "1" : "0";
            mt.FIN_Costing_Lot_Size  = FIN_Costing_Lot_Size.Text;
            mt.FIN_Price_Control     = FIN_Price_Control.SelectedValue;
            mt.FIN_Price_Unit        = FIN_Price_Unit.Text;
            mt.FIN_Origin_Group      = FIN_Origin_Group.Text;    
            mt.FIN_Profit_Center     = FIN_Profit_Center.SelectedValue;   
            mt.FIN_Currency          = FIN_Currency.Text;        
            mt.FIN_Variance_Key      = FIN_Variance_Key.Text;
            mt.FIN_Moving_Price      = FIN_Moving_Price.Text.ToString();
 
        }                            
        #endregion                   

        #region 方法 SetDefaultValue(设置默认值, 并禁用输入)
        public void SetDefaultValue()
        {
            switch(Category)
            {
                case "RAW":
                    FIN_Valuation_Class.SelectedValue = "3000";
                    FIN_Costing_Lot_Size.Text = "1000";
                    FIN_Price_Control.SelectedValue = "V";
                    FIN_Price_Unit.Text = "1";
                    FIN_Origin_Group.Text = "RAW";
                    FIN_Currency.Text = "CNY";
                    FIN_Variance_Key.Text = "000001";
                    FIN_Material_Origin.Checked = true;
                    FIN_Profit_Center.SelectedValue = "89";
                    SetEnable(false, FIN_Valuation_Class, FIN_Costing_Lot_Size, FIN_Price_Control, FIN_Price_Unit, FIN_Origin_Group, FIN_Currency, FIN_Variance_Key, FIN_Material_Origin, FIN_Profit_Center);
                    SetForeColor(Color.Orange, FIN_Valuation_Class_L, FIN_Costing_Lot_Size_L, FIN_Price_Control_L, FIN_Price_Unit_L, FIN_Origin_Group_L, FIN_Currency_L, FIN_Variance_Key_L, FIN_Material_Origin_L, FIN_Profit_Center_L);
                    //if (FORM == "FORM-T003")
                    //{
                    //    FIN_Valuation_Class.SelectedValue = "3000";
                    //    FIN_Costing_Lot_Size.Text = "1000";
                    //    FIN_Price_Control.SelectedValue = "V";
                    //    FIN_Do_Not_Cost.Checked = false;
                    //    FIN_Origin_Group.Text = "RAW";
                    //    FIN_With_Qty_Structure.Checked = true;
                    //    FIN_Variance_Key.Text = "000001";
                    //    FIN_Material_Origin.Checked = true;
                    //    if ((Page as PMDC).Distribute.SelectedValue == "DECO")
                    //    {
                    //        FIN_Profit_Center.SelectedValue = "D4239003";
                    //    }
                    //    else if ((Page as PMDC).Distribute.SelectedValue == "PKG")
                    //    {
                    //        FIN_Profit_Center.SelectedValue = "P4239001";
                    //    }
                    //    else
                    //    {
                    //        FIN_Profit_Center.SelectedValue = "";
                    //    }
                    //    SetEnable(false, FIN_Valuation_Class, FIN_Costing_Lot_Size, FIN_Price_Control, FIN_Do_Not_Cost, FIN_Origin_Group, FIN_With_Qty_Structure, FIN_Variance_Key, FIN_Material_Origin);
                    //    SetForeColor(Color.Orange, FIN_Valuation_Class_L, FIN_Costing_Lot_Size_L, FIN_Price_Control_L, FIN_Do_Not_Cost_L, FIN_Origin_Group_L, FIN_With_Qty_Structure_L, FIN_Variance_Key_L, FIN_Material_Origin_L);
                    //}
                    break;
                case "PACK":
                    FIN_Valuation_Class.SelectedValue   = "3050";
                    FIN_Material_Origin.Checked         = true;
                    FIN_Costing_Lot_Size.Text           = "1000";
                    FIN_Price_Control.SelectedValue     = "V";
                    FIN_Price_Unit.Text                 = "1";
                    FIN_Origin_Group.Text               = "RAW";
                    FIN_Currency.Text                   = "CNY";
                    FIN_Variance_Key.Text               = "000001";
                    FIN_Profit_Center.SelectedValue     = "89";
                    SetEnable(false, FIN_Valuation_Class, FIN_Material_Origin, FIN_Costing_Lot_Size, FIN_Price_Control, FIN_Price_Unit, FIN_Origin_Group, FIN_Currency, FIN_Variance_Key, FIN_Profit_Center);
                    SetForeColor(Color.Orange, FIN_Valuation_Class_L, FIN_Material_Origin_L, FIN_Costing_Lot_Size_L, FIN_Price_Control_L, FIN_Price_Unit_L, FIN_Origin_Group_L, FIN_Currency_L, FIN_Variance_Key_L, FIN_Profit_Center_L);
                    break;
                case "SEFI":
                    FIN_Valuation_Class.SelectedValue   = "7900";
                    FIN_Price_Control.SelectedValue     = "S";
                    FIN_Price_Unit.Text                 = "1";
                    FIN_Currency.Text                   = "CNY";
                    FIN_Variance_Key.Text               = "000001";
                    FIN_Material_Origin.Checked         = true;
                    if (FORM == "FORM-T008")
                    {
                        if (!string.IsNullOrEmpty((Page as PMDC).TabMaterial2.Planning1.PLA_Fix_Lot_Size.Text))
                        {
                            FIN_Costing_Lot_Size.Text = (Page as PMDC).TabMaterial2.Planning1.PLA_Fix_Lot_Size.Text;
                        }
                        else
                        {
                            FIN_Costing_Lot_Size.Text = "200";
                        }
                        //FIN_Costing_Lot_Size.Text = "200";
                        FIN_Profit_Center.SelectedValue = "D4239003";
                        FIN_Do_Not_Cost.Checked = false;
                        FIN_With_Qty_Structure.Checked = true;
                        SetEnable(false, FIN_Valuation_Class, FIN_Costing_Lot_Size, FIN_Price_Control, FIN_Price_Unit, FIN_Currency, FIN_Variance_Key, FIN_Material_Origin, FIN_Do_Not_Cost, FIN_With_Qty_Structure);
                        SetForeColor(Color.Orange, FIN_Valuation_Class_L, FIN_Costing_Lot_Size_L, FIN_Price_Control_L, FIN_Price_Unit_L, FIN_Currency_L, FIN_Variance_Key_L, FIN_Do_Not_Cost_L, FIN_With_Qty_Structure_L, FIN_Material_Origin_L);

                    }
                    else if (FORM == "FORM-T011")
                    {
                        if (!string.IsNullOrEmpty((Page as PMDC).TabMaterial2.Planning1.PLA_Fix_Lot_Size.Text))
                        {
                            FIN_Costing_Lot_Size.Text = (Page as PMDC).TabMaterial2.Planning1.PLA_Fix_Lot_Size.Text;
                        }
                        else
                        {
                            FIN_Costing_Lot_Size.Text = "1000";
                        }
                        //FIN_Costing_Lot_Size.Text = "1000";
                        FIN_Profit_Center.SelectedValue = "P4239001";
                        FIN_Do_Not_Cost.Checked = false;
                        FIN_With_Qty_Structure.Checked = true;
                        SetEnable(false, FIN_Valuation_Class, FIN_Costing_Lot_Size, FIN_Price_Control, FIN_Price_Unit, FIN_Currency, FIN_Variance_Key, FIN_Material_Origin, FIN_Do_Not_Cost, FIN_With_Qty_Structure);
                        SetForeColor(Color.Orange, FIN_Valuation_Class_L, FIN_Costing_Lot_Size_L, FIN_Price_Control_L, FIN_Price_Unit_L, FIN_Currency_L, FIN_Variance_Key_L, FIN_Do_Not_Cost_L, FIN_With_Qty_Structure_L, FIN_Material_Origin_L);
                    }
                    else if (FORM == "FORM-T011-1")
                    {
                        FIN_Valuation_Class.SelectedValue = "7900";
                        FIN_Price_Control.SelectedValue = "S";
                        FIN_Price_Unit.Text = "1";
                        FIN_Material_Origin.Checked = true;
                        FIN_Variance_Key.Text = "000001";
                        FIN_Costing_Lot_Size.Text = "1000";
                        FIN_Profit_Center.SelectedValue = "P4239001";
                        FIN_Do_Not_Cost.Checked = false;
                        FIN_With_Qty_Structure.Checked = true;
                        FIN_Costing_Lot_Size.Text = "200";
                        SetEnable(false, FIN_Valuation_Class, FIN_Costing_Lot_Size, FIN_Price_Control, FIN_Price_Unit, FIN_Variance_Key, FIN_Material_Origin, FIN_Do_Not_Cost, FIN_With_Qty_Structure, FIN_Variance_Key, FIN_Profit_Center);
                        SetForeColor(Color.Orange, FIN_Valuation_Class_L, FIN_Costing_Lot_Size_L, FIN_Price_Control_L, FIN_Price_Unit_L, FIN_Variance_Key_L, FIN_Do_Not_Cost_L, FIN_With_Qty_Structure_L, FIN_Material_Origin_L, FIN_Variance_Key_L, FIN_Profit_Center_L);
                    }
                    else if (FORM == "FORM-T007")
                    {
                        FIN_Valuation_Class.SelectedValue = "7900";
                        FIN_Price_Unit.Text = "1";
                        FIN_Price_Control.SelectedValue = "S";
                        FIN_Do_Not_Cost.Checked = false;
                        FIN_With_Qty_Structure.Checked = true;
                        FIN_Material_Origin.Checked = true;
                        FIN_Variance_Key.Text = "000001";
                        FIN_Profit_Center.SelectedValue = "D4239003";
                        FIN_Costing_Lot_Size.Text = "200";
                        SetEnable(false, FIN_Valuation_Class, FIN_Costing_Lot_Size, FIN_Price_Control, FIN_Price_Unit, FIN_Variance_Key, FIN_Material_Origin, FIN_Do_Not_Cost, FIN_With_Qty_Structure, FIN_Profit_Center);
                        SetForeColor(Color.Orange, FIN_Valuation_Class_L, FIN_Costing_Lot_Size_L, FIN_Price_Control_L, FIN_Price_Unit_L, FIN_Variance_Key_L, FIN_Do_Not_Cost_L, FIN_With_Qty_Structure_L, FIN_Material_Origin_L, FIN_Profit_Center_L);
                    }
                    else
                    {
                        FIN_Costing_Lot_Size.Text = "1000";
                    }
                    SetEnable(false, FIN_Valuation_Class, FIN_Costing_Lot_Size, FIN_Price_Control, FIN_Price_Unit, FIN_Currency, FIN_Variance_Key, FIN_Material_Origin);
                    SetForeColor(Color.Orange, FIN_Valuation_Class_L, FIN_Costing_Lot_Size_L, FIN_Price_Control_L, FIN_Price_Unit_L, FIN_Currency_L, FIN_Variance_Key_L);
                    break;
                case "FINI":
                case "TRADE":
                    
                    FIN_Costing_Lot_Size.Text           = "1000";
                    //FIN_Price_Control.SelectedValue     = "S";
                    FIN_Price_Unit.Text                 = "1";
                    FIN_Currency.Text                   = "CNY";
                    FIN_Variance_Key.Text               = "000001";
                    FIN_Material_Origin.Checked         = true;

                    if (FORM == "FORM-064")
                    {
                         
                        FIN_Costing_Lot_Size.Text = "1";
                        FIN_Price_Control.SelectedValue = "V";
                        FIN_Valuation_Class.SelectedValue = "Z005";
                    }
                    else if (FORM == "FORM-074")
                    {
                        FIN_Price_Control.SelectedValue = "S";
                        FIN_Costing_Lot_Size.Text = "1";
                        FIN_Valuation_Class.SelectedValue = "Z001";

                    }

                    else if (FORM == "FORM-067")
                    {
                     
                        FIN_Costing_Lot_Size.Text = "1";
                        FIN_Material_Origin.Checked = true;
                        FIN_Price_Unit.Text = "1";
                        FIN_Price_Control.SelectedValue = "S";
                        FIN_Variance_Key.Text = "000001";
                        FIN_Valuation_Class.SelectedValue = "Z001";
                    }
                    else if (FORM == "FORM-015")
                    {
                        FIN_Valuation_Class.SelectedValue = "Z005";
                        FIN_Price_Unit.Text = "1000";
                        FIN_Price_Control.SelectedValue = "V";
                        //SetForeColor(Color.Blue, FIN_Moving_Price_L);
                    }
                    else if (FORM == "FORM-012")
                    {
                        FIN_Price_Control.SelectedValue = "S";
                        //FIN_Valuation_Class.SelectedValue = "7920";
                        if ((Page as PMDC).TabMaterial4.Planning1.PLA_ICD.SelectedValue == "Y")
                        {
                            FIN_Valuation_Class.SelectedValue = "Z001";
                        }
                        else
                        {
                            FIN_Valuation_Class.SelectedValue = "7920";
                        }
                    }
                    else if (FORM == "FORM-062")
                    {
                        FIN_Costing_Lot_Size.Text = "1";
                        FIN_Material_Origin.Checked = true;
                        FIN_Price_Unit.Text = "1";
                        FIN_Price_Control.SelectedValue = "S";
                        FIN_Variance_Key.Text = "000001";
                        FIN_Valuation_Class.SelectedValue = "Z001";
                    }
                    else if (FORM == "FORM-062-1")
                    {
                        FIN_Costing_Lot_Size.Text = "1000";
                        FIN_Price_Unit.Text = "1";
                        FIN_Currency.Text = "CNY";
                        FIN_Variance_Key.Text = "000001";
                        FIN_Material_Origin.Checked = true;
                        FIN_Valuation_Class.SelectedValue = "7920";
                        FIN_Price_Control.SelectedValue = "S";
                    }
                    else if (FORM == "FORM-031-1" || FORM == "FORM-031-2")
                    {
                        FIN_Valuation_Class.SelectedValue = "7920";
                        FIN_Price_Control.SelectedValue = "S";
                    }
                    else if (FORM == "FORM-010")
                    {
                        FIN_Valuation_Class.SelectedValue = "7920";
                        FIN_Costing_Lot_Size.Text = "1000";
                        FIN_Price_Control.SelectedValue     = "S";
                        FIN_Price_Unit.Text = "1";
                        FIN_Variance_Key.Text = "000001";
                        FIN_Material_Origin.Checked = true;
                    }
                    else if (FORM == "FORM-T009")
                    {
                        FIN_Valuation_Class.SelectedValue = "Z005";
                        FIN_Price_Unit.Text = "1000";
                        FIN_Price_Control.SelectedValue = "V";
                        if ((Page as PMDC).Distribute.SelectedValue == "PKG")
                        {
                            FIN_Profit_Center.SelectedValue = "P4239001";
                        }
                        else if ((Page as PMDC).Distribute.SelectedValue == "DECO")
                        {
                            FIN_Profit_Center.SelectedValue = "D4239003";
                        }
                        else
                        {
                            FIN_Profit_Center.SelectedValue = "";
                        }
                    }
                    else if (FORM == "FORM-T010")
                    {
                        FIN_Valuation_Class.SelectedValue = "7920";
                        FIN_Price_Control.SelectedValue = "S";
                        FIN_Price_Unit.Text = "1";
                        FIN_Do_Not_Cost.Checked = false;
                        FIN_With_Qty_Structure.Checked = true;
                        FIN_Material_Origin.Checked = true;
                        FIN_Variance_Key.Text = "000001";
                        FIN_Costing_Lot_Size.Text = "10";
                        //if (!string.IsNullOrEmpty((Page as PMDC).TabMaterial1.Planning1.PLA_Fix_Lot_Size.Text))
                        //{
                        //    FIN_Costing_Lot_Size.Text = (Page as PMDC).TabMaterial1.Planning1.PLA_Fix_Lot_Size.Text;
                        //}
                        //else
                        //{
                        //    FIN_Costing_Lot_Size.Text = "10";
                        //}
                        SetEnable(false, FIN_Valuation_Class, FIN_Price_Control, FIN_Price_Unit, FIN_Do_Not_Cost, FIN_With_Qty_Structure, FIN_Material_Origin, FIN_Variance_Key, FIN_Costing_Lot_Size);
                        SetForeColor(Color.Orange, FIN_Valuation_Class_L, FIN_Price_Control_L, FIN_Price_Unit_L, FIN_Do_Not_Cost_L, FIN_With_Qty_Structure_L, FIN_Material_Origin_L, FIN_Variance_Key_L, FIN_Costing_Lot_Size_L);
                    }
                    else if (FORM == "FORM-T012")
                    {
                        FIN_Valuation_Class.SelectedValue = "Z005";
                        FIN_Price_Unit.Text = "1000";
                        FIN_Price_Control.SelectedValue = "V";
                        FIN_Profit_Center.SelectedValue = "P4239001";
                        SetForeColor(Color.Orange, FIN_Valuation_Class_L, FIN_Price_Control_L, FIN_Price_Unit_L, FIN_Profit_Center_L);

                    }
                    else if (FORM == "FORM-T006")
                    {
                        FIN_Valuation_Class.SelectedValue = "7920";
                        FIN_Price_Control.SelectedValue = "S";
                        FIN_Price_Unit.Text = "1";
                        FIN_Do_Not_Cost.Checked = false;
                        FIN_With_Qty_Structure.Checked = true;
                        FIN_Material_Origin.Checked = true;
                        FIN_Variance_Key.Text = "000001";
                        FIN_Costing_Lot_Size.Text = "200";
                        SetEnable(false, FIN_Valuation_Class, FIN_Price_Control, FIN_Price_Unit, FIN_Do_Not_Cost, FIN_With_Qty_Structure, FIN_Material_Origin, FIN_Variance_Key, FIN_Costing_Lot_Size);
                        SetForeColor(Color.Orange, FIN_Valuation_Class_L, FIN_Price_Control_L, FIN_Price_Unit_L, FIN_Do_Not_Cost_L, FIN_With_Qty_Structure_L, FIN_Material_Origin_L, FIN_Variance_Key_L, FIN_Costing_Lot_Size_L);

                    }
                    else if (FORM == "FORM-TW-003")
                    {
                        FIN_Price_Control.SelectedValue     = "V";
                        FIN_Price_Unit.Text = "1000";
                        FIN_Valuation_Class.SelectedValue = "3000";
                        FIN_Origin_Group.Text = "RAW";
                        FIN_Do_Not_Cost.Checked = false;
                        FIN_With_Qty_Structure.Checked = true;
                        SetForeColor(Color.Orange, FIN_Profit_Center_L,FIN_With_Qty_Structure_L, FIN_Do_Not_Cost_L, FIN_Origin_Group_L);
                        SetEnable(false, FIN_With_Qty_Structure, FIN_Do_Not_Cost, FIN_Origin_Group);
                    }
                    else if (FORM == "FORM-T003")
                    {
                        //FIN_Valuation_Class.SelectedValue = "3000";
                        //FIN_Costing_Lot_Size.Text = "1000";
                        //FIN_Price_Control.SelectedValue = "V";
                        //FIN_Do_Not_Cost.Checked = false;
                        //FIN_Origin_Group.Text = "RAW";
                        ////FIN_With_Qty_Structure.Checked = true;
                        //FIN_Variance_Key.Text = "000001";
                        //FIN_Material_Origin.Checked = true;
                        //FIN_Price_Unit.Text = "1000";
                        if ((Page as PMDC).Actions.SelectedValue == "Revision")
                        {
                            FIN_With_Qty_Structure.Checked = false;
                            FIN_Valuation_Class.SelectedValue = "3000";
                            FIN_Costing_Lot_Size.Text = "1000";
                            FIN_Price_Control.SelectedValue = "V";
                            FIN_Do_Not_Cost.Checked = false;
                            FIN_Origin_Group.Text = "RAW";
                            //FIN_With_Qty_Structure.Checked = true;
                            FIN_Variance_Key.Text = "000001";
                            FIN_Material_Origin.Checked = true;
                            FIN_Price_Unit.Text = "1000";
                            SetEnable(true, FIN_Do_Not_Cost, FIN_With_Qty_Structure);
                            SetForeColor(Color.Black, FIN_With_Qty_Structure_L, FIN_Do_Not_Cost_L);
                            SetEnable(false, FIN_Valuation_Class, FIN_Costing_Lot_Size, FIN_Price_Control, FIN_Origin_Group, FIN_Variance_Key, FIN_Material_Origin, FIN_Price_Unit);
                            SetForeColor(Color.Orange, FIN_Valuation_Class_L, FIN_Costing_Lot_Size_L, FIN_Price_Control_L, FIN_Origin_Group_L, FIN_Variance_Key_L, FIN_Material_Origin_L, FIN_Profit_Center_L, FIN_Price_Unit_L);
                        }
                        else
                        {
                            FIN_Valuation_Class.SelectedValue = "3000";
                            FIN_Costing_Lot_Size.Text = "1000";
                            FIN_Price_Control.SelectedValue = "V";
                            FIN_Do_Not_Cost.Checked = false;
                            FIN_Origin_Group.Text = "RAW";
                            FIN_With_Qty_Structure.Checked = true;
                            FIN_Variance_Key.Text = "000001";
                            FIN_Material_Origin.Checked = true;
                            FIN_Price_Unit.Text = "1000";
                            SetEnable(false, FIN_Valuation_Class, FIN_Costing_Lot_Size, FIN_Price_Control, FIN_Origin_Group, FIN_Variance_Key, FIN_Material_Origin, FIN_Price_Unit, FIN_With_Qty_Structure, FIN_Do_Not_Cost);
                            SetForeColor(Color.Orange, FIN_Valuation_Class_L, FIN_Costing_Lot_Size_L, FIN_Price_Control_L, FIN_Origin_Group_L, FIN_Variance_Key_L, FIN_Material_Origin_L, FIN_Profit_Center_L, FIN_Price_Unit_L, FIN_With_Qty_Structure_L, FIN_Do_Not_Cost_L);
                        }
                        
                        //SetEnable(false, FIN_Valuation_Class, FIN_Costing_Lot_Size, FIN_Price_Control, FIN_Do_Not_Cost, FIN_Origin_Group, FIN_With_Qty_Structure, FIN_Variance_Key, FIN_Material_Origin, FIN_Price_Unit);
                        //SetForeColor(Color.Orange, FIN_Valuation_Class_L, FIN_Costing_Lot_Size_L, FIN_Price_Control_L, FIN_Do_Not_Cost_L, FIN_Origin_Group_L, FIN_With_Qty_Structure_L, FIN_Variance_Key_L, FIN_Material_Origin_L, FIN_Profit_Center_L, FIN_Price_Unit_L);
                    }
                    else if (FORM == "FORM-T018")
                    {
                        if ((Page as PMDC).Actions.SelectedValue == "Revision")
                        {
                            FIN_Valuation_Class.SelectedValue = "3000";
                            FIN_Costing_Lot_Size.Text = "1000";
                            FIN_Price_Control.SelectedValue = "V";
                            FIN_Do_Not_Cost.Checked = false;
                            FIN_Origin_Group.Text = "RAW";
                            FIN_With_Qty_Structure.Checked = false;
                            FIN_Variance_Key.Text = "000001";
                            FIN_Material_Origin.Checked = true;
                            FIN_Price_Unit.Text = "1000";
                            SetEnable(true, FIN_Do_Not_Cost, FIN_With_Qty_Structure);
                            SetForeColor(Color.Black, FIN_With_Qty_Structure_L, FIN_Do_Not_Cost_L);
                            SetEnable(false, FIN_Valuation_Class, FIN_Costing_Lot_Size, FIN_Price_Control, FIN_Origin_Group, FIN_Variance_Key, FIN_Material_Origin, FIN_Price_Unit);
                            SetForeColor(Color.Orange, FIN_Valuation_Class_L, FIN_Costing_Lot_Size_L, FIN_Price_Control_L, FIN_Origin_Group_L, FIN_Variance_Key_L, FIN_Material_Origin_L, FIN_Profit_Center_L, FIN_Price_Unit_L);
                        }
                        else
                        {
                            FIN_Valuation_Class.SelectedValue = "3000";
                            FIN_Costing_Lot_Size.Text = "1000";
                            FIN_Price_Control.SelectedValue = "V";
                            FIN_Do_Not_Cost.Checked = false;
                            FIN_Origin_Group.Text = "RAW";
                            FIN_With_Qty_Structure.Checked = true;
                            FIN_Variance_Key.Text = "000001";
                            FIN_Material_Origin.Checked = true;
                            FIN_Price_Unit.Text = "1000";
                            SetEnable(false, FIN_Valuation_Class, FIN_Costing_Lot_Size, FIN_Price_Control, FIN_Do_Not_Cost, FIN_Origin_Group, FIN_With_Qty_Structure, FIN_Variance_Key, FIN_Material_Origin, FIN_Price_Unit);
                            SetForeColor(Color.Orange, FIN_Valuation_Class_L, FIN_Costing_Lot_Size_L, FIN_Price_Control_L, FIN_Do_Not_Cost_L, FIN_Origin_Group_L, FIN_With_Qty_Structure_L, FIN_Variance_Key_L, FIN_Material_Origin_L, FIN_Profit_Center_L, FIN_Price_Unit_L);
                        }
                        //FIN_Valuation_Class.SelectedValue = "3000";
                        //FIN_Costing_Lot_Size.Text = "1000";
                        //FIN_Price_Control.SelectedValue = "V";
                        //FIN_Do_Not_Cost.Checked = false;
                        //FIN_Origin_Group.Text = "RAW";
                        //FIN_With_Qty_Structure.Checked = true;
                        //FIN_Variance_Key.Text = "000001";
                        //FIN_Material_Origin.Checked = true;
                        //FIN_Price_Unit.Text = "1000";
                        //SetEnable(false, FIN_Valuation_Class, FIN_Costing_Lot_Size, FIN_Price_Control, FIN_Do_Not_Cost, FIN_Origin_Group, FIN_With_Qty_Structure, FIN_Variance_Key, FIN_Material_Origin, FIN_Price_Unit);
                        //SetForeColor(Color.Orange, FIN_Valuation_Class_L, FIN_Costing_Lot_Size_L, FIN_Price_Control_L, FIN_Do_Not_Cost_L, FIN_Origin_Group_L, FIN_With_Qty_Structure_L, FIN_Variance_Key_L, FIN_Material_Origin_L, FIN_Profit_Center_L, FIN_Price_Unit_L);
                    }
                    else if (FORM == "FORM-TW-010")
                    {
                        FIN_Price_Control.SelectedValue = "S";
                        FIN_Price_Unit.Text = "1";
                        FIN_Valuation_Class.SelectedValue = "7920";
                        FIN_Do_Not_Cost.Checked = false;
                        FIN_With_Qty_Structure.Checked = true;
                        FIN_Costing_Lot_Size.Text = "10";
                        SetForeColor(Color.Orange, FIN_With_Qty_Structure_L);
                    }
                    else if (FORM == "FORM-TW-011")
                    {
                        FIN_Price_Control.SelectedValue = "S";
                        FIN_Price_Unit.Text = "1";
                        FIN_Valuation_Class.SelectedValue = "7900";
                        FIN_Do_Not_Cost.Checked = false;
                        FIN_With_Qty_Structure.Checked = true;
                        FIN_Costing_Lot_Size.Text = "1000";
                        FIN_Profit_Center.SelectedValue = "P4239001";
                        SetForeColor(Color.Orange, FIN_With_Qty_Structure_L, FIN_Profit_Center_L);
                        SetEnable(false, FIN_Do_Not_Cost, FIN_With_Qty_Structure);
                    }
                    else if (FORM == "FORM-TW-004")
                    {
                        FIN_Price_Control.SelectedValue = "V";
                        FIN_Price_Unit.Text = "1000";
                        FIN_Valuation_Class.SelectedValue = "3050";
                        FIN_Do_Not_Cost.Checked = false;
                        FIN_With_Qty_Structure.Checked = true;
                        FIN_Costing_Lot_Size.Text = "1000";
                        if (TaskAPI.Process == "TW NPL Application-DECO")
                        {
                            FIN_Profit_Center.Text = "D4239003";
                            SetEnable(false, FIN_Profit_Center);
                        }
                        FIN_Origin_Group.Text = "RAW";
                        SetForeColor(Color.Orange,FIN_Do_Not_Cost_L, FIN_Origin_Group_L,FIN_With_Qty_Structure_L, FIN_Profit_Center_L);
                        SetEnable(false, FIN_Origin_Group, FIN_Valuation_Class, FIN_Price_Control, FIN_Price_Unit, FIN_Material_Origin
                               , FIN_Variance_Key, FIN_Costing_Lot_Size, FIN_Do_Not_Cost, FIN_With_Qty_Structure);

                    }
                    else if (FORM == "FORM-TW-007-1" || FORM == "FORM-TW-007")
                    {
                        FIN_Price_Control_L.Text = "Price control indicator";
                        FIN_Price_Control.SelectedValue = "S";
                        FIN_Price_Unit.Text = "1";
                        FIN_Valuation_Class.SelectedValue = "7920";
                        FIN_Do_Not_Cost.Checked = false;
                        FIN_With_Qty_Structure.Checked = true;
                        FIN_Costing_Lot_Size.Text = "1000";
                        FIN_Profit_Center.SelectedValue = "D4239003";
                        SetForeColor(Color.Orange,FIN_Do_Not_Cost_L, FIN_With_Qty_Structure_L, FIN_Profit_Center_L);
                        SetEnable(false, FIN_Valuation_Class,  FIN_Price_Control,  FIN_Price_Unit,   FIN_Material_Origin,  FIN_Profit_Center
                                  ,  FIN_Variance_Key, FIN_Costing_Lot_Size,  FIN_Do_Not_Cost,  FIN_With_Qty_Structure);

                    }
                    else
                    {
                        FIN_Price_Control.SelectedValue = "S";
                        FIN_Valuation_Class.SelectedValue = "7920";
                    }
                    SetEnable(false, FIN_Valuation_Class, FIN_Costing_Lot_Size, FIN_Price_Control, FIN_Price_Unit, FIN_Currency, FIN_Variance_Key, FIN_Material_Origin);
                    SetForeColor(Color.Orange, FIN_Valuation_Class_L, FIN_Costing_Lot_Size_L, FIN_Price_Control_L, FIN_Price_Unit_L, FIN_Currency_L, FIN_Variance_Key_L, FIN_Material_Origin_L);
                    break;
            }
            if (TaskAPI.Process.Contains("TW"))
            {
                FIN_Price_Unit.Text = "1000";
                FIN_Costing_Lot_Size.Text = "1000";
            }
        }
        #endregion

        #region 方法 SetToolTip(设置控件 ToolTip)
        public void SetToolTip()
        {
            switch(Category)
            {
                case "RAW":
                    FIN_Valuation_Class.ToolTip     = "评估类(默认为3000: Raw materials)";
                    FIN_Costing_Lot_Size.ToolTip    = "成本核算批量(默认为1000)";
                    FIN_Price_Control.ToolTip       = "价格控制(默认为V: 移动平均价)";
                    FIN_Price_Unit.ToolTip          = "价格单位(默认为1)";
                    FIN_Origin_Group.ToolTip        = "成本要素子组的原始组(默认为RAW)";
                    FIN_Currency.ToolTip            = "货币码(默认为CNY)";
                    FIN_Variance_Key.ToolTip        = "差异码";
                    FIN_Material_Origin.ToolTip     = "原始组（默认勾选）";
                    break;
                case "PACK":
                    FIN_Valuation_Class.ToolTip     = "评估类(默认为3050: Packaging materials)";
                    FIN_Material_Origin.ToolTip     = "原始组(默认勾选)";
                    FIN_Costing_Lot_Size.ToolTip    = "成本核算批量(默认为1000)";
                    FIN_Price_Control.ToolTip       = "价格控制(默认为V: 移动平均价)";
                    FIN_Price_Unit.ToolTip          = "价格单位(默认为1)";
                    FIN_Origin_Group.ToolTip        = "成本要素子组的原始组(默认为RAW)";
                    FIN_Currency.ToolTip            = "货币码(默认为CNY)";
                    FIN_Variance_Key.ToolTip        = "差异码(默认为 000001)";
                    FIN_Profit_Center.ToolTip       = "利润中心(销售渠道，默认为89)";
                    FIN_Material_Origin.ToolTip     = "原始组（默认勾选）";
                    break;
                case "SEFI":
                    FIN_Valuation_Class.ToolTip     = "评估类(默认为7900: Semifinished products)";
                    FIN_Costing_Lot_Size.ToolTip    = "成本核算批量(默认为1000)";
                    FIN_Price_Control.ToolTip       = "价格控制(默认为S:Standard price)";
                    FIN_Price_Unit.ToolTip          = "价格单位(默认为1)";
                    FIN_Currency.ToolTip            = "货币码(默认为CNY)";
                    FIN_Variance_Key.ToolTip        = "差异码(默认为 000001)";
                    FIN_Material_Origin.ToolTip     = "原始组(默认勾选)";
                    FIN_Origin_Group.ToolTip        = "成本要素子组的原始组（默认为RAW）";
                    if (FORM == "FORM-T008")
                    {
                        FIN_Valuation_Class.ToolTip = "評估類 (默认爲7920)";
                        FIN_Price_Control.ToolTip = "價格控制指示符 默認爲S";
                        FIN_Price_Unit.ToolTip = "價格單位(默认爲1)";
                        FIN_Do_Not_Cost.ToolTip = "無成本核算\n新建時默認不打勾";
                        FIN_With_Qty_Structure.ToolTip = "物料根據數量結構進行成本核算\n新建時默認打勾";
                        FIN_Material_Origin.ToolTip = "物料相關的源\n默認打勾";
                        FIN_Variance_Key.ToolTip = "差异碼\n默認000001";
                        FIN_Costing_Lot_Size.ToolTip = "批量産品成本核算(若Fix Lot Size維護數值，則取Fix Lot Size數值，否則默認為1000)";
                        FIN_Profit_Center.ToolTip = "利潤中心 DECO默认为D4239003";
                    }
                    if (FORM == "FORM-T011")
                    {
                        FIN_Valuation_Class.ToolTip = "評估類 (默认爲7900)";
                        FIN_Price_Control.ToolTip = "價格控制指示符 默認爲S";
                        FIN_Price_Unit.ToolTip = "價格單位(默认爲1)";
                        FIN_Do_Not_Cost.ToolTip = "無成本核算\n新建時默認不打勾";
                        FIN_With_Qty_Structure.ToolTip = "物料根據數量結構進行成本核算\n新建時默認打勾";
                        FIN_Material_Origin.ToolTip = "物料相關的源\n默認打勾";
                        FIN_Variance_Key.ToolTip = "差异碼\n默認000001";
                        FIN_Costing_Lot_Size.ToolTip = "批量産品成本核算(若設定了Fix Lot Size,則等于Fix Lot Size,若沒有設定則爲1000)";
                        FIN_Profit_Center.ToolTip = "利潤中心 PKG默认为P4239001";
                    }
                    if (FORM == "FORM-T007")
                    {
                        FIN_Valuation_Class.ToolTip = "評估類 (默认爲7900)";
                        FIN_Price_Control.ToolTip = "價格控制指示符 默認爲S";
                        FIN_Price_Unit.ToolTip = "價格單位(默认爲1)";
                        FIN_Do_Not_Cost.ToolTip = "無成本核算\n新建時默認不打勾";
                        FIN_With_Qty_Structure.ToolTip = "物料根據數量結構進行成本核算\n新建時默認打勾";
                        FIN_Variance_Key.ToolTip = "差异碼\n默認000001";
                        FIN_Profit_Center.ToolTip = "利潤中心 DECO默认为D4239003";
                        FIN_Costing_Lot_Size.ToolTip = "批量産品成本核算(默認爲200)";
                    }
                    if (FORM == "FORM-T011-1")
                    {
                        FIN_Valuation_Class.ToolTip = "評估類 (默认爲7900)";
                        FIN_Price_Control.ToolTip = "價格控制指示符 默認爲S";
                        FIN_Price_Unit.ToolTip = "價格單位(默认爲1)";
                        FIN_Do_Not_Cost.ToolTip = "無成本核算\n新建時默認不打勾";
                        FIN_With_Qty_Structure.ToolTip = "物料根據數量結構進行成本核算\n新建時默認打勾";
                        FIN_Variance_Key.ToolTip = "差异碼\n默認000001";
                        FIN_Profit_Center.ToolTip = "利潤中心 DECO默认为P4239001";
                        FIN_Costing_Lot_Size.ToolTip = "批量産品成本核算(默認爲200)";
                    }
                    break;
                case "FINI":
                case "TRADE":
                    FIN_Valuation_Class.ToolTip     = "评估类";
                    FIN_Costing_Lot_Size.ToolTip    = "成本核算批量(默认为1000)";
                    FIN_Price_Control.ToolTip       = "价格控制(默认为S:Standard price)";
                    FIN_Price_Unit.ToolTip          = "价格单位(默认为1)";
                    FIN_Currency.ToolTip            = "货币码(默认为CNY)";
                    FIN_Variance_Key.ToolTip        = "差异码(默认为 000001)";
                    FIN_Material_Origin.ToolTip     = "原始组(默认勾选)";
                    FIN_Origin_Group.ToolTip        = "成本要素子组的原始组";

                    if (FORM == "FORM-001")
                    {
                        FIN_Valuation_Class.ToolTip = "评估类(默认:7920)";
                    }
                    if (FORM == "FORM-067")
                    {
                        FIN_Costing_Lot_Size.ToolTip = "成本核算批量(默认为1)";
                    }
                    if (FORM == "FORM-015")
                    {
                        FIN_Valuation_Class.ToolTip = "评估类(默认为Z005)";
                        FIN_Price_Control.ToolTip = "价格控制(默认为V)";
                        FIN_Moving_Price.ToolTip = "初始价格";
                    }
                    if (FORM.IndexOf("T")!=-1)
                    {
                        FIN_Valuation_Class.ToolTip = "評估類";
                        FIN_Costing_Lot_Size.ToolTip = "批量產品成本核算";
                        FIN_Price_Control.ToolTip = "價格控制指示符";
                        FIN_Price_Unit.ToolTip = "價格單位";
                        FIN_Variance_Key.ToolTip = "差異碼 ";
                        FIN_Material_Origin.ToolTip = "物料相關的源";
                        FIN_Origin_Group.ToolTip = "作為成本要素子組的原始組 ";
                        FIN_Do_Not_Cost.ToolTip = "無成本核算(新建時默認不勾選)";
                        FIN_With_Qty_Structure.ToolTip = "物料根據數量結構進行成本核算(新建時默認勾選)";
                        FIN_Profit_Center.ToolTip = "利潤中心";
                        if (FORM == "FORM-TW-011")
                        {
                            FIN_Costing_Lot_Size.ToolTip = "批量産品成本核算,若設定了Fix Lot Size,則等于Fix Lot Size,若沒有設定則爲1000";
                        }
                    }
                    if (FORM == "FORM-T009" || FORM == "FORM-T012")
                    {
                        FIN_Valuation_Class.ToolTip = "評估類";
                        FIN_Price_Control.ToolTip = "價格控制指示符 ";
                        FIN_Price_Unit.ToolTip = "價格單位";
                        FIN_Profit_Center.ToolTip = "利潤中心";
                    }
                    if (FORM == "FORM-T006")
                    {
                        FIN_Valuation_Class.ToolTip = "評估類 (默认爲7920)";
                        FIN_Price_Control.ToolTip = "價格控制指示符 默認爲S";
                        FIN_Price_Unit.ToolTip = "價格單位(默认爲1)";
                        FIN_Do_Not_Cost.ToolTip = "無成本核算\n新建時默認不打勾";
                        FIN_With_Qty_Structure.ToolTip = "物料根據數量結構進行成本核算\n新建時默認打勾";
                        FIN_Material_Origin.ToolTip = "物料相關的源\n默認打勾";
                        FIN_Variance_Key.ToolTip = "差异碼\n默認000001";
                        FIN_Costing_Lot_Size.ToolTip = "批量産品成本核算\n默認為200";
                    }
                    if (FORM == "FORM-T010")
                    {
                        FIN_Valuation_Class.ToolTip = "評估類 (默认爲7920)";
                        FIN_Price_Control.ToolTip = "價格控制指示符 默認爲S";
                        FIN_Price_Unit.ToolTip = "價格單位(默认爲1)";
                        FIN_Do_Not_Cost.ToolTip = "無成本核算\n新建時默認不打勾";
                        FIN_With_Qty_Structure.ToolTip = "物料根據數量結構進行成本核算\n新建時默認打勾";
                        FIN_Material_Origin.ToolTip = "物料相關的源\n默認打勾";
                        FIN_Variance_Key.ToolTip = "差异碼\n默認000001";
                        FIN_Costing_Lot_Size.ToolTip = "批量産品成本核算\n默認為10";
                    }
                    if (FORM == "FORM-T018" || FORM == "FORM-T003")
                    {
                        FIN_Valuation_Class.ToolTip = "評估類 (默认爲3000)";
                        FIN_Price_Control.ToolTip = "價格控制指示符 默認爲V";
                        FIN_Price_Unit.ToolTip = "價格單位(默认爲1000)";
                        FIN_Do_Not_Cost.ToolTip = "無成本核算\n新建時默認不打勾";
                        FIN_With_Qty_Structure.ToolTip = "物料根據數量結構進行成本核算\n新建時默認打勾";
                        FIN_Material_Origin.ToolTip = "物料相關的源\n默認打勾";
                        FIN_Variance_Key.ToolTip = "差异碼\n默認000001";
                        FIN_Costing_Lot_Size.ToolTip = "批量産品成本核算\n默認為1000";
                        FIN_Origin_Group.ToolTip = "作爲成本要素子組的原始組 默認為RAW";
                        FIN_Profit_Center.ToolTip = "利潤中心 DECO默認為D4239003,PKG默认为P4239001";
                    }

                    break;
            }
        }
        #endregion

        #region 方法 DataValidation(数据验证)
        public List<string> DataValidation(mdc_Material mt, string Sheet)
        {
            List<Regular> regs = new List<Regular>();

            if (FORM == "FORM-015")
            {
                if (Action != "S")
                {
                    regs.Add(new Regular(RegularExp.NotEmpty,mt.FIN_Moving_Price,Sheet+ "Moving Price 为必填"));

                }
                return Validation(regs);
            }
            //如果当前 Tabs 是隐藏的情况，退出
            if (!(IsUsed && (Action == "C" || Action == "E")))
            {
                return new List<string>();
            }
            akzo_RegularCheck(ref regs, RegularExp.NotEmpty, FIN_Profit_Center_L, mt.FIN_Profit_Center, Sheet + "Profit Center为必填");

            return Validation(regs);
        }
        #endregion
    }
}
